export class BarChartOptionAttribute{
    constructor() {
        this.xAxisarr = [];
        this.seriesData = [];
    }
}
export class BarChart {
    constructor(echarts,chartId,params){
        this.echarts = echarts
        this.chartId = chartId
        this.params = params
        this.myChart = null
        this.initChart()
    }
    initChart() {
        this.myChart = this.echarts.init(document.getElementById(this.chartId));
        this.updataChart(this.params)
    }
    updataChart(params) {
        let option = {
            title: {
                // text: 'ECharts 入门示例'
            },
            tooltip: {},
            grid:{
                left:'10%'
            },
            legend: {
                // data:['销量']
            },
            xAxis: {
                data: params.xAxisarr
            },
            yAxis: {},
            series: [{
                name: '销量',
                type: 'bar',
                data:params.seriesData
            }]
        };
      
        this.myChart.setOption(option);
    }
}


export class LineChartOptionAttribute{
    constructor() {
        this.xAxisarr = [];
        this.seriesData = [];
    }
}
export class LineChart {
    constructor(echarts,chartId,params){
        this.echarts = echarts
        this.chartId = chartId
        this.params = params
        this.myChart = null
        this.initChart()
    }
    initChart() {
        this.myChart = this.echarts.init(document.getElementById(this.chartId));
        this.updataChart(this.params)
    }
    updataChart(params) {
        let option = {
            xAxis: {
                type: 'category',
                data: params.xAxisarr
            },
            yAxis: {
                type: 'value'
            },
            series: [{
                data: params.seriesData,
                type: 'line'
            }]
        };
      
        this.myChart.setOption(option);
    }
}

export class PieChartOptionAttribute{
    constructor() {
        this.seriesData = [];
    }
}
export class PieChart {
    constructor(echarts,chartId,params){
        this.echarts = echarts
        this.chartId = chartId
        this.params = params
        this.myChart = null
        this.initChart()
    }
    initChart() {
        this.myChart = this.echarts.init(document.getElementById(this.chartId));
        this.updataChart(this.params)
    }
    updataChart(params) {
        let option = {
            title: {
                text: '某站点用户访问来源',
                subtext: '纯属虚构',
                left: 'center'
            },
            tooltip: {
                trigger: 'item'
            },
            legend: {
                orient: 'vertical',
                left: 'left',
            },
            series: [
                {
                    name: '访问来源',
                    type: 'pie',
                    radius: '50%',
                    data: params.seriesData,
                    emphasis: {
                        itemStyle: {
                            shadowBlur: 10,
                            shadowOffsetX: 0,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        }
                    }
                }
            ]
        };
      
        this.myChart.setOption(option);
    }
}